﻿package adminLogic;

import vo.admin.AddUserPanelVO;
import vo.admin.LoginPanelVO;
import vo.admin.MainPanelVO;
import vo.admin.ModifyUserPanelVO;
import logicInterface.AdminLogicInterface;

public class MockAdminLogic implements AdminLogicInterface{
	private LoginPanelVO lpvo;
	private AddUserPanelVO aupvo;
	private MainPanelVO mpvo;
	private ModifyUserPanelVO mupvo;

	private String state;
	private String message;
	
	public MockAdminLogic(){
		lpvo=new LoginPanelVO();
		aupvo=new AddUserPanelVO();
		mpvo=new MainPanelVO();
		mupvo=new ModifyUserPanelVO();

		state="Login";
		message="";
		
		mpvo.setUserData(new String[][]{{"jzf","顾客"},{"sb","销售经理"},{"250","总经理"}});
	}

	public LoginPanelVO getLpvo() {
		return lpvo;
	}

	public void setLpvo(LoginPanelVO lpvo) {
		this.lpvo = lpvo;
	}



	public AddUserPanelVO getAupvo() {
		return aupvo;
	}



	public void setAupvo(AddUserPanelVO aupvo) {
		this.aupvo = aupvo;
	}



	public MainPanelVO getMpvo() {
		return mpvo;
	}



	public void setMpvo(MainPanelVO mpvo) {
		this.mpvo = mpvo;
	}



	public ModifyUserPanelVO getMupvo() {
		return mupvo;
	}



	public void setMupvo(ModifyUserPanelVO mupvo) {
		this.mupvo = mupvo;
	}



	public String getState() {
		return state;
	}

	public String getMessage() {
		return message;
	}

	public String searchUser() {
		message="";
		switch(mpvo.getUserType()){
		case 1:
			mpvo.setUserData(new String[][]{{"jzf","顾客"}});
			break;
		case 2:
			mpvo.setUserData(new String[][]{{"sb","销售经理"}});
			break;
		case 3:
			mpvo.setUserData(new String[][]{{"250","总经理"}});
			break;
		}
		return "Main";
	}


	public String addUser() {
		message="添加成功";
		return state;
	}

	public String modifyUser() {
		message="修改成功";
		return state;
	}
	
    public String toAddUser() {
		state="AddUser";
		message="";
		return state;
	}



	public String toModifyUser() {
		message="";
		if(mpvo.getSelectedRow()==-1){
			message="请选中所要修改的行！";
		}else{
			state="ModifyUser";
		}
		return state;
	}


	public String deleteUser() {
		message="";
		if(mpvo.getSelectedRow()==-1){
			message="请选中所要删除的行！";
		}
		return state;
	}
	
	public String login() {
		if(lpvo.getPassword().equals(lpvo.getUsername())){
			state="Main";
			message="";
		}else{
			message="登录失败";
		}
		return state;
	}

	public String logout() {
		message="";
		state="Login";
		return state;
	}

	public String toMain() {
		message="";
		state="Main";
		return state;
	}

	@Override
	public void setMessage(String s) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void setState(String s) {
		// TODO Auto-generated method stub
		
	}



}
